This invention relates to a method for memory-mapped file management for programs that run in a kernel mode and, more particularly, to such a method that assures that there will not be a system failure in the event that memory use exceeds that which can be accommodated by the kernel mode program.
As the size of applications and the operating systems that run them grow larger, so do their demands on memory. Consequently, all modern operating systems provide a form of virtual memory to applications. One of these operating systems is Windows NT (a product of the Microsoft Corporation, Redmond Wash.). A virtual memory system provides an address space that is generally much larger than the available random access memory (RAM). In essence, virtual memory treats both disk and RAM alike and swaps data from disk to RAM as it is required for an operating application, in a transparent manner.
Windows NT provides a page-based virtual memory management scheme that allows applications to realize a 32-bit linear address space for 4 gigabytes (GB) of memory. As a result, each application has its own private address space from which it can use the lower 2 GBxe2x80x94the system reserves the upper 2 GB of every process""s address space for its own use. Windows NT handles exhaustion of virtual memory differently when operating in its respective memory management modes, i.e., user mode and kernel mode.
Applications generally run in the user mode and have access only to their own address space and must use established interfaces to obtain other system services, thus protecting the operating system and improving its performance. The user mode allows the creation of very large files that are substantially indeterminate in size.
The NT kernel mode is a highly privileged mode of operation where the code has direct access to all memory, including the address space of all user mode processes and applications. However, in developing the NT kernel mode, Microsoft did not prevent Windows NT from xe2x80x9ccrashingxe2x80x9d when all available virtual memory was exhausted. Consequently, this fact places a practical limit of 100 megabytes (on a typical system) on the amount of memory that can be used for any particular file, which amount is generally sufficient for most uses. But, if a kernel mode task, such as a printer driver procedure, creates a file that is larger than the amount of available virtual memory, the result is that the operating system signals a system failure, requiring a restart of the system and a potential loss of data.
Certain computers employ printer drivers that operate in the kernel mode. Applications running on such computers may, under certain circumstances, transfer very large documents to the printer driver. This results in the printer driver processing large amounts of data. For example, when booklet printing, the printer must store the data temporarily on disk, resulting in, at times, excessively large files. In such case, if the file size exceeds the amount of available kernel virtual memory, the system will experience a failure.
Accordingly, it is an object of the invention to configure files in such a manner that programs running in the kernel mode will not experience a system failure in the event a file exceeds a size limit that can be accommodated by a kernel mode program.
The method of the invention enables a procedure to handle a large data file, wherein the procedure has a fixed, limited allocation of memory that is less than the size of the data file. The method segments the large data file into one or more subfiles, wherein each subfile is of a datasize that does not exceed the limited allocation. Thereafter, the method sequentially activates the procedure to operate upon each subfile, until all subfiles have been processed. During this action, and after processing, subfiles are closed to free the virtual memory space.
More particularly, the method enables the procedure to handle such a large file by initially responding to a request to do so by establishing a master file. Then the procedure writes the file into one or more segment files, each segment file having a size that does not exceed the fixed allocation size. Each segment file is then listed in the master file. Thereafter, the procedure responds to a read request, by using the master file to access one of the segment files and to store such in. available memory space. Then the procedure performs a required operation with respect to the segment file and proceeds to a next segment file in the same manner, until all segment files have been processed. This action avoids any file from exceeding the fixed allocation of memory for the procedure. As required, segment files are closed to free virtual memory for subsequent use.